package com.example.sneakerappserver.exception;

import com.example.sneakerappserver.pojo.ResponseMessage;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

import java.util.logging.Logger;

@RestController // 统一处理
public class GlobalExceptionHandlerAdvice {
//    Logger log = (Logger) LoggerFactory.getLogger(GlobalExceptionHandlerAdvice.class);
    @ExceptionHandler({Exception.class})    // 什么异常的统一处理
    public ResponseMessage handlerException(Exception e, HttpServletRequest request, HttpServletResponse response) {

        return new ResponseMessage(500, "error", null);
    }
}
